import { UserResponse } from '@entities/User/model/User'
import { rtkApi } from './rtkApi'

export const userApi = rtkApi.enhanceEndpoints({ addTagTypes: ['users'] }).injectEndpoints({
  endpoints: (build) => ({
    getCurrentUser: build.query<UserResponse, void>({
      providesTags: ['users'],
      query: () => ({
        method: 'GET',
        url: 'users/current',
      }),
    }),
  }),
})
export const { useGetCurrentUserQuery } = userApi
export const {
  endpoints: { getCurrentUser },
} = userApi
